package com.ta.consumer;

import com.ta.mapper.OrderMapper;
import com.ta.pojo.Order;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class dlQueueConsumer {
    @Autowired
    private OrderMapper orderMapper;

    @RabbitListener(queues = "dlQueue")
    public void orderConsumer(Integer oid){
        System.out.println(oid);
        if (oid == null) {
            return;
        }

        Order order = orderMapper.selectOid(new Integer(oid));
        System.out.println(oid);
        if (order == null) {
            return;
        }

        /*15分钟没有支付,关闭订单*/
        if (order.getStatus().equals(0)) {
            orderMapper.modifyStatus(Integer.valueOf(oid), 2, "系统", new Date(), null);
        }
    }
}
